package cn.yuhh.api.exception;


import cn.yuhh.core.type.ResponseHeader;

/**
 * Created by werewolf on 2016/11/24.
 */
public class ApiException extends RuntimeException{

    //Internal Server Error
    private Integer code = ResponseHeader.INTERNAL_SERVER_ERROR.getCode();

    ResponseHeader header;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public ApiException() {
    }

    public ApiException(String message) {
        super(message);
    }


    public ApiException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    public ApiException(ResponseHeader header) {
        super(header.getMessage());
        this.header = header;
        this.code = header.getCode();
    }

    public ApiException(String message, Integer code, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public ApiException(Throwable cause) {
        super(cause);
    }

    public ResponseHeader getHeader() {
        return header;
    }

    public void setHeader(ResponseHeader header) {
        this.header = header;
    }
}
